# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=opencascade
pkgver=7.8.1
pkgrel=0
pkgdesc="SDK for development of applications dealing with 3D CAD data"
url="https://dev.opencascade.org/"
# s390x blocked by vtk -> netcdf
arch="all !s390x"
license="LGPL-2.1-only"
makedepends="
	cmake
	doxygen
	freeimage-dev
	freetype-dev
	libxi-dev
	libxmu-dev
	mesa-dev
	qt5-qtbase-dev
	rapidjson-dev
	samurai
	tk-dev
	vtk-dev
	"
subpackages="$pkgname-doc $pkgname-dev"
# remove updatecache on next update
source="$pkgname-$pkgver-updatecache.tar.gz::https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V${pkgver//./_}.tar.gz
	no_mallinfo.patch
	no_feenableexcept.patch
	no_backtrace.patch
	x11vtkconflict.patch
	drop-nonsense-from-cmake.patch
	"
builddir="$srcdir/OCCT-${pkgver//./_}"
options="!check" # No tests provided :-/

build() {
	# Disabling ffmpeg for now, as VTK already uses ffmpeg in version 5, while OCC only
	# builds with ffmpeg4 right now. vtk-dev depends on ffmpeg-dev which conflics with
	# ffmpeg4-dev. Once patched to build with ffmpeg-dev (not ffmpeg4-dev), ffmpeg support
	# should be re-enabled.
	#
	# Detecting TBB is broken, we disable it for now.
	cmake -B build -G Ninja -Wno-dev \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_FFMPEG=OFF \
		-DUSE_FREEIMAGE=ON \
		-DUSE_RAPIDJSON=ON \
		-DUSE_TBB=OFF \
		-DUSE_VTK=ON \
		-D3RDPARTY_VTK_INCLUDE_DIR=/usr/include/vtk-9.3/
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Fix broken cmake files
	find "$pkgdir"/usr/lib/cmake/opencascade -type f -exec \
		sed -i {} -e 's/\${OCCT_INSTALL_BIN_LETTER}//g' \;
}

sha512sums="
807c1f8732926cfdabcfbdf8d6a0e76b8dba1a1e614afe084a467ffb4cfd80623f5e3afa7e9905b1ac96667c93e01b5f98ceaa8948a576a1093d98df98cc8f81  opencascade-7.8.1-updatecache.tar.gz
e04cb898ec16c57ea5f2e9e79f6616153b7f6e4ddcad815f5d28898a692e26e1054a8f3321e6ee8616a915b10d45927f5e596c4f096c5333be910eaea751cce3  no_mallinfo.patch
b039b8fce696bfd0f53309a72adab4065780bf1755da6208040157e9383deb0061ad8927a6f160730f431cbebe3fdd1eaa7967b38da4a245a8d9306042d97629  no_feenableexcept.patch
86dceb6e8309e18f5ea72ce2e3524ff08dc761ffe76557d62a1a4f2824ca0e2f9dfc194cae22164aaaf5ad9a15a6ec0f1fef443241aa2ccb0a2140de217c8a90  no_backtrace.patch
8f5abf58f4a1b84aee99c75bbaeb2267655f306b6a3e12600a4db34201106dd380c7e30e37d4db81841be8ba9455604a10bfaa6e50e73801097ce141840f3d8e  x11vtkconflict.patch
ed289ac71cf8426609038361122a54e76f8c7a78989555be619c2ee44233a32bfd386cfee345d701e6a986e7a3df29e7d36dc14cd7a9f11d055350938e29c619  drop-nonsense-from-cmake.patch
"
